package com.ziyun.pop.modules.storeMember.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ziyun.pop.modules.storeMember.dao.ErpUserBaseInfoDao;
import com.ziyun.pop.modules.storeMember.entity.UserBaseInfoEntity;
import com.ziyun.pop.modules.storeMember.service.UserBaseInfoService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author gaosheng
 * @date 2018-09-30 10:37
 */
@Service("userBaseInfoService")
public class UserBaseInfoServiceImpl extends ServiceImpl<ErpUserBaseInfoDao, UserBaseInfoEntity> implements UserBaseInfoService {

    @Override
    public UserBaseInfoEntity getEntityByMemberId(Integer memberId) {
        return this.baseMapper.selectById(memberId);
    }

    @Override
    public List<UserBaseInfoEntity> queryUserList(Map<String, Object> params) {
        List<UserBaseInfoEntity> userBaseInfoEntities = this.baseMapper.queryUserList(params);
        // 过滤门店已删除的会员
        List<UserBaseInfoEntity> filterList = userBaseInfoEntities.stream()
                .filter(user -> user.getMerchantsDel() == 0)
                .collect(Collectors.toList());
        return filterList;
    }

    @Override
    public List<UserBaseInfoEntity> queryPageUser(Long sellerId) {
        return this.baseMapper.queryPageUser(sellerId);
    }

    @Override
    public void updateByMap(Map<String, Object> map, Long userId) {
        baseMapper.updateByMap(map, userId);
    }
}
